--------------------------------------------------------------------------------
-- Date: 	23.05.02 (dd.mm.yy)
--
-- Script: 	Biped Selector
--
-- Version:	1.3
-- Max ver:	4
-- Type:	Macroscript
--
-- Written: Saku Partamies
-- Email:	saku@partamies.com
-- www:     www.partamies.com
--
-- Design:	Juha Takabe
-- Email:	juha_takabe@hotmail.com
-- www:		http://www.saunalahti.fi/jukota/


-- About the script:
--  This script is made for Character Studio animators.
--  It creates a floater interface allowing easier selection of biped's
--  different bodyparts.

-- Installation:
-- 1) Copy BipedSelector13 -directory to your 3dsmax\scripts -directory.
-- 2) Run the script from 3dsmax\scripts\BipedSelector13 -directory.
-- 3) Open Customize User Interface Dialog and from Toolbars page
--    select a Category: Scripts. Drag Biped Selector 1.3 -Action
--    to existing toolbar or create a new one where to drag the script.

-- How to use:
--  1. Use Add Biped to list -button to select biped(s) you want to use.
--	   You can select any bodypart of biped to add that one to list.
--  2. Select biped from list.
--  3. Click different bodyparts in floater to select bodyparts of your biped.
--  4. Doubleclicking a biped name in the list will remove that one.

-- Notes:
-- Biped Selector -script saves biped list with .max file when scene is saved.
-- Therefore when you load .max file which contains saved biped list, Biped Selector
-- will be immeaditely ready to use with no need to re-select your biped objects.
----------------------------------------------------------------------------------


macroScript BipedSelector tooltip:"Biped Selector 1.3" Category:"Scripts"
(

if biped_float != undefined
	then (closeRolloutFloater biped_float)

biped_float = NewRolloutFloater   "Biped Selector 1.3" 160 495
(

persistent global biped_selector_obj
persistent global bs_object_list
persistent global bs_object_names_list

if bs_object_list == undefined then bs_object_list = #()
if bs_object_names_list == undefined then bs_object_names_list = #()

try ( biped_selector_obj = bs_object_list[1] ) catch()

if bs_object_list.count > 0 then (
	local check_var
	for i=0 to (bs_object_list.count-1) do (
		if i < (bs_object_list.count-1) then (check_var = bs_object_list.count - i) else (check_var=1)
			if (isValidNode bs_object_list[check_var] == false) then (
				try ( deleteItem bs_object_list check_var ) catch()
				try ( deleteItem bs_object_names_list check_var ) catch()
			)
	)
)

rollout select_roll "Pick Biped"
(
	fn check_for_biped obj =
		(
			return_value = false
			if classof obj == biped_object then return_value = true
			return_value
		)

	pickbutton select_biped_btn "Add Biped to list" width:100 align:#center filter:check_for_biped \
	tooltip:"Select any bodypart of your Biped object to make it active"
	listBox bipeds_lbox "" items:bs_object_names_list height:5

	on select_biped_btn picked obj do
	(
		if classof obj == biped_object then (
			local check = true
			for i=1 to bs_object_list.count do (
				if bs_object_list[i]==(biped.getNode obj 13) then (check=false; exit)
			)
			if check==true then (
				append bs_object_list (biped.getNode obj 13)
				append bs_object_names_list (biped.getNode obj 13).name
				bipeds_lbox.items = bs_object_names_list
				bipeds_lbox.selection = bs_object_list.count
		
				biped_selector_obj = (biped.getNode obj 13)
				
			--	print bs_object_list
			--	print obj
			)
		)
	)
	
	on bipeds_lbox doubleClicked num do (
		deleteItem bs_object_list num
		deleteItem bs_object_names_list num
		bipeds_lbox.items = bs_object_names_list

		local object_list_count = bs_object_list.count
		bipeds_lbox.selection = bs_object_list.count
		
		try ( biped_selector_obj = (biped.getNode bs_object_list[object_list_count] 13) ) catch()
		if bs_object_list.count == 0 then biped_selector_obj = undefined
		
--		print bs_object_list
	)

	on bipeds_lbox selected num do (
		try ( biped_selector_obj = (biped.getNode bs_object_list[num] 13) ) catch()
	)
)
addRollout select_roll biped_float rolledUp:false


rollout parts_roll "Select" width:160 height:400
(
	button select_head_btn "Head" pos:[46,8] width:40 height:28 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_head.bmp", undefined, 1, 1, 1, 1, 1) toolTip:"Head"
	button select_neck_btn "-" pos:[56,40] width:20 height:16 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_neck.bmp", undefined, 1, 1, 1, 1, 1) toolTip:"Neck"

	button spine5_btn "-" pos:[36,60] width:60 height:10 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_spine.bmp", undefined, 1, 1, 1, 1, 1)
	button spine4_btn "-" pos:[36,72] width:60 height:10 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_spine.bmp", undefined, 1, 1, 1, 1, 1)
	button spine3_btn "-" pos:[36,84] width:60 height:10 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_spine.bmp", undefined, 1, 1, 1, 1, 1)
	button spine2_btn "-" pos:[36,96] width:60 height:10 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_spine.bmp", undefined, 1, 1, 1, 1, 1)
	button spine1_btn "-" pos:[36,108] width:60 height:10 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_spine.bmp", undefined, 1, 1, 1, 1, 1)

	button pelvis_btn "Pelvis" pos:[36,120] width:60 height:20 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_pelvis.bmp", undefined, 1, 1, 1, 1, 1) toolTip:"Pelvis"

	button select_root_btn "Root" pos:[46,143] width:40 height:22 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_root.bmp", "bipsel_root_mask.bmp", 1, 1, 1, 1, 1) toolTip:"Root"

	button select_rclav_btn "R" pos:[20,45] width:24 height:12 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_green.bmp", undefined, 1, 1, 1, 1, 1)
	button select_lclav_btn "L" pos:[88,45] width:24 height:12 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_blue.bmp", undefined, 1, 1, 1, 1, 1)

	button select_ruparm_btn "R" pos:[10,62] width:16 height:36 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_green.bmp", undefined, 1, 1, 1, 1, 1)
	button select_luparm_btn "L" pos:[106,62] width:16 height:36 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_blue.bmp", undefined, 1, 1, 1, 1, 1)

	button select_rforarm_btn "R" pos:[10,104] width:16 height:36 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_green.bmp", undefined, 1, 1, 1, 1, 1)
	button select_lforarm_btn "L" pos:[106,104] width:16 height:36 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_blue.bmp", undefined, 1, 1, 1, 1, 1)

	button select_rhand_btn "R" pos:[10,145] width:16 height:16 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_green.bmp", undefined, 1, 1, 1, 1, 1)
	button select_lhand_btn "L" pos:[106,145] width:16 height:16 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_blue.bmp", undefined, 1, 1, 1, 1, 1)

	button rtight_btn "R" pos:[36,168] width:20 height:40 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_green.bmp", undefined, 1, 1, 1, 1, 1)
	button ltight_btn "L" pos:[76,168] width:20 height:40 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_blue.bmp", undefined, 1, 1, 1, 1, 1)

	button rcalf_btn "R" pos:[36,213] width:20 height:40 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_green.bmp", undefined, 1, 1, 1, 1, 1)
	button lcalf_btn "L" pos:[76,213] width:20 height:40 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_blue.bmp", undefined, 1, 1, 1, 1, 1)

	button rfoot_btn "R" pos:[26,258] width:30 height:15 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_green.bmp", undefined, 1, 1, 1, 1, 1)
	button lfoot_btn "L" pos:[76,258] width:30 height:15 images:#(getdir #maxroot+"scripts\BipedSelector13\bipsel_blue.bmp", undefined, 1, 1, 1, 1, 1)

	button select_bip_btn "Biped ALL" pos:[6,278] width:120 height:15 toolTip:"Selects all bodyparts of your Biped"

	
	
	on select_head_btn pressed do
		try ( select (biped.getNode biped_selector_obj #Head) ) catch()
	on select_neck_btn pressed do
		try ( select (biped.getNode biped_selector_obj 17) ) catch()
	on spine5_btn pressed do
		try ( select (biped.getNode biped_selector_obj 9 link:5) ) catch()
	on spine4_btn pressed do
		try ( select (biped.getNode biped_selector_obj 9 link:4) ) catch()
	on spine3_btn pressed do
		try ( select (biped.getNode biped_selector_obj 9 link:3) ) catch()
	on spine2_btn pressed do
		try ( select (biped.getNode biped_selector_obj 9 link:2) ) catch()
	on spine1_btn pressed do
		try ( select (biped.getNode biped_selector_obj 9 link:1) ) catch()
	on pelvis_btn pressed do
		try ( select (biped.getNode biped_selector_obj 12) ) catch()
	on select_root_btn pressed do
		try ( select (biped.getNode biped_selector_obj 13) ) catch()
	on select_rclav_btn pressed do
		try ( select (biped.getNode biped_selector_obj 2) ) catch()
	on select_lclav_btn pressed do
		try ( select (biped.getNode biped_selector_obj 1) ) catch()
	on select_ruparm_btn pressed do
		try ( select (biped.getNode biped_selector_obj 2 link:2) ) catch()
	on select_luparm_btn pressed do
		try ( select (biped.getNode biped_selector_obj 1 link:2) ) catch()
	on select_rforarm_btn pressed do
		try ( select (biped.getNode biped_selector_obj 2 link:3) ) catch()
	on select_lforarm_btn pressed do
		try ( select (biped.getNode biped_selector_obj 1 link:3) ) catch()
	on select_rhand_btn pressed do
		try ( select (biped.getNode biped_selector_obj 2 link:4) ) catch()
	on select_lhand_btn pressed do
		try ( select (biped.getNode biped_selector_obj 1 link:4) ) catch()
	on rtight_btn pressed do
		try ( select (biped.getNode biped_selector_obj 6) ) catch()
	on ltight_btn pressed do
		try ( select (biped.getNode biped_selector_obj 5) ) catch()
	on rcalf_btn pressed do
		try ( select (biped.getNode biped_selector_obj 6 link:2) ) catch()
	on lcalf_btn pressed do
		try ( select (biped.getNode biped_selector_obj 5 link:2) ) catch()
	on rfoot_btn pressed do
		try ( select (biped.getNode biped_selector_obj 6 link:3) ) catch()
	on lfoot_btn pressed do
		try ( select (biped.getNode biped_selector_obj 5 link:3) ) catch()
	on select_bip_btn pressed do
	(
			disableSceneRedraw()
			clearNodeSelection()
			for i=1 to 19 do (
				for j=1 to 15 do (
					try ( selectMore (biped.getNode biped_selector_obj i link:j ) ) catch()
				)
			)
			enableSceneRedraw()
			reDrawViews()
	
		)
)
addRollout parts_roll biped_float rolledUp:false



rollout sets_roll "Selection Sets"
(

	button select_neckall_btn "Neck ALL" pos:[5,5] width:124 height:15 toolTip:"Neck ALL"
	
	button select_spineall_btn "Spine ALL" pos:[5,25] width:124 height:15 toolTip:"Spine ALL"
	
	button select_bothuarms_btn "Both U_Arms" pos:[5,45] width:124 height:15 toolTip:"Both Upperarms"
	
	button select_boththighs_btn "Both Thighs" pos:[5,65] width:124 height:15 toolTip:"Both Thighs"



	on select_neckall_btn pressed do (
		disableSceneRedraw()
		clearNodeSelection()
		for i=1 to 5 do (try ( selectMore (biped.getNode biped_selector_obj 17 link:i ) ) catch() )
		enableSceneRedraw()
		reDrawViews()
	)
	

	on select_spineall_btn pressed do (
		disableSceneRedraw()
		clearNodeSelection()
		for i=1 to 5 do (try ( selectMore (biped.getNode biped_selector_obj 9 link:i ) ) catch() )
		enableSceneRedraw()
		reDrawViews()
	)
	
		on select_bothuarms_btn pressed do (
		disableSceneRedraw()
		try ( select (biped.getNode biped_selector_obj 1 link:2 ) ) catch()
		try ( selectMore (biped.getNode biped_selector_obj 2 link:2 ) ) catch()
		enableSceneRedraw()
		reDrawViews()
	)
	
		on select_boththighs_btn pressed do (
		disableSceneRedraw()
		try ( select (biped.getNode biped_selector_obj 5) ) catch()
		try ( selectMore (biped.getNode biped_selector_obj 6) ) catch()
		enableSceneRedraw()
		reDrawViews()
	)
	
	
	
)
addRollout sets_roll biped_float rolledUp:true



rollout fingers_roll "Fingers"
(

	label script "Right and Left Fingers"

	button select_rfinger1_1_btn "1" pos:[5,25] width:25 height:15
	button select_rfinger1_2_btn "2" pos:[30,25] width:25 height:15
	button select_rfinger1_3_btn "3" pos:[55,25] width:25 height:15

	button select_rfinger2_1_btn "1" pos:[5,45] width:40 height:15
	button select_rfinger2_2_btn "2" pos:[45,45] width:40 height:15
	button select_rfinger2_3_btn "3" pos:[85,45] width:40 height:15

	button select_rfinger3_1_btn "1" pos:[5,65] width:40 height:15
	button select_rfinger3_2_btn "2" pos:[45,65] width:40 height:15
	button select_rfinger3_3_btn "3" pos:[85,65] width:40 height:15

	button select_rfinger4_1_btn "1" pos:[5,85] width:40 height:15
	button select_rfinger4_2_btn "2" pos:[45,85] width:40 height:15
	button select_rfinger4_3_btn "3" pos:[85,85] width:40 height:15

	button select_rfinger5_1_btn "1" pos:[5,105] width:40 height:15
	button select_rfinger5_2_btn "2" pos:[45,105] width:40 height:15
	button select_rfinger5_3_btn "3" pos:[85,105] width:40 height:15

	button select_rfinger_all_btn "All R" pos:[90,25] width:30 height:15 tooltip:"All right fingers"

	button select_lfinger1_1_btn "1" pos:[5,135] width:25 height:15
	button select_lfinger1_2_btn "2" pos:[30,135] width:25 height:15
	button select_lfinger1_3_btn "3" pos:[55,135] width:25 height:15

	button select_lfinger2_1_btn "1" pos:[5,155] width:40 height:15
	button select_lfinger2_2_btn "2" pos:[45,155] width:40 height:15
	button select_lfinger2_3_btn "3" pos:[85,155] width:40 height:15

	button select_lfinger3_1_btn "1" pos:[5,175] width:40 height:15
	button select_lfinger3_2_btn "2" pos:[45,175] width:40 height:15
	button select_lfinger3_3_btn "3" pos:[85,175] width:40 height:15

	button select_lfinger4_1_btn "1" pos:[5,195] width:40 height:15
	button select_lfinger4_2_btn "2" pos:[45,195] width:40 height:15
	button select_lfinger4_3_btn "3" pos:[85,195] width:40 height:15

	button select_lfinger5_1_btn "1" pos:[5,215] width:40 height:15
	button select_lfinger5_2_btn "2" pos:[45,215] width:40 height:15
	button select_lfinger5_3_btn "3" pos:[85,215] width:40 height:15

	button select_lfinger_all_btn "All L" pos:[90,135] width:30 height:15 tooltip:"All left fingers"


	on select_lfinger_all_btn pressed do (
		disableSceneReDraw()
		try (
			local bip = biped_selector_obj.controller
			local fingerArr = for i = 1 to (bip.fingers * bip.fingerLinks) \
				collect(biped.getNode bip 3 link:i)
			select fingerArr
			) catch()
		enableSceneRedraw()
		reDrawViews()
	)	

	on select_rfinger_all_btn pressed do (
		disableSceneReDraw()
		try (
			local bip = biped_selector_obj.controller
			local fingerArr = for i = 1 to (bip.fingers * bip.fingerLinks) \
				collect(biped.getNode bip 4 link:i)
			select fingerArr
			) catch()
		enableSceneRedraw()
		reDrawViews()
	)	


	on select_rfinger1_1_btn pressed do
		try ( select (biped.getNode biped_selector_obj 4 ) ) catch()
	
	on select_rfinger1_2_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks != 1 then select (biped.getNode biped_selector_obj 4 link:2 )
		) catch()
	)

	on select_rfinger1_3_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 4 link:3 )
		) catch()
	)

	on select_rfinger2_1_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 4 link:4 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 4 link:3 )
		if biped_selector_obj.controller.fingerlinks == 1 then select (biped.getNode biped_selector_obj 4 link:2 )
		) catch()
	)
	
	on select_rfinger2_2_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 4 link:5 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 4 link:4 )
		) catch()
	)
	
	on select_rfinger2_3_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 4 link:6 )
		) catch()
	)

	on select_rfinger3_1_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 4 link:7 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 4 link:5 )
		if biped_selector_obj.controller.fingerlinks == 1 then select (biped.getNode biped_selector_obj 4 link:3 )
		) catch()
	)
		
	on select_rfinger3_2_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 4 link:8 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 4 link:6 )
		) catch()
	)

	on select_rfinger3_3_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 4 link:9 )
		) catch()
	)

	on select_rfinger4_1_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 4 link:10 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 4 link:7 )
		if biped_selector_obj.controller.fingerlinks == 1 then select (biped.getNode biped_selector_obj 4 link:4 )
		) catch()
	)

	on select_rfinger4_2_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 4 link:11 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 4 link:8 )
		) catch()
	)

	on select_rfinger4_3_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 4 link:12 )
		) catch()
	)

	on select_rfinger5_1_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 4 link:13 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 4 link:9 )
		if biped_selector_obj.controller.fingerlinks == 1 then select (biped.getNode biped_selector_obj 4 link:5 )
		) catch()
	)

	on select_rfinger5_2_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 4 link:14 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 4 link:10 )
		) catch()
	)
	
	on select_rfinger5_3_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 4 link:15 )
		) catch()
	)



	on select_lfinger1_1_btn pressed do
		try ( select (biped.getNode biped_selector_obj 3 ) ) catch()
	
	on select_lfinger1_2_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks != 1 then select (biped.getNode biped_selector_obj 3 link:2 )
		) catch()
	)

	on select_lfinger1_3_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 3 link:3 )
		) catch()
	)

	on select_lfinger2_1_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 3 link:4 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 3 link:3 )
		if biped_selector_obj.controller.fingerlinks == 1 then select (biped.getNode biped_selector_obj 3 link:2 )
		) catch()
	)
	
	on select_lfinger2_2_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 3 link:5 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 3 link:4 )
		) catch()
	)
	
	on select_lfinger2_3_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 3 link:6 )
		) catch()
	)

	on select_lfinger3_1_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 3 link:7 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 3 link:5 )
		if biped_selector_obj.controller.fingerlinks == 1 then select (biped.getNode biped_selector_obj 3 link:3 )
		) catch()
	)
		
	on select_lfinger3_2_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 3 link:8 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 3 link:6 )
		) catch()
	)

	on select_lfinger3_3_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 3 link:9 )
		) catch()
	)

	on select_lfinger4_1_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 3 link:10 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 3 link:7 )
		if biped_selector_obj.controller.fingerlinks == 1 then select (biped.getNode biped_selector_obj 3 link:4 )
		) catch()
	)

	on select_lfinger4_2_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 3 link:11 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 3 link:8 )
		) catch()
	)

	on select_lfinger4_3_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 3 link:12 )
		) catch()
	)

	on select_lfinger5_1_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 3 link:13 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 3 link:9 )
		if biped_selector_obj.controller.fingerlinks == 1 then select (biped.getNode biped_selector_obj 3 link:5 )
		) catch()
	)

	on select_lfinger5_2_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 3 link:14 )
		if biped_selector_obj.controller.fingerlinks == 2 then select (biped.getNode biped_selector_obj 3 link:10 )
		) catch()
	)
	
	on select_lfinger5_3_btn pressed do (
		try (
		if biped_selector_obj.controller.fingerlinks == 3 then select (biped.getNode biped_selector_obj 3 link:15 )
		) catch()
	)
)
addRollout fingers_roll biped_float rolledUp:true


rollout toes_roll "Toes"
(
	label script "Right and Left Toes"

	button select_rtoe1_1_btn "1" pos:[5,25] width:25 height:15
	button select_rtoe1_2_btn "2" pos:[30,25] width:25 height:15
	button select_rtoe1_3_btn "3" pos:[55,25] width:25 height:15

	button select_rtoe2_1_btn "1" pos:[5,45] width:40 height:15
	button select_rtoe2_2_btn "2" pos:[45,45] width:40 height:15
	button select_rtoe2_3_btn "3" pos:[85,45] width:40 height:15

	button select_rtoe3_1_btn "1" pos:[5,65] width:40 height:15
	button select_rtoe3_2_btn "2" pos:[45,65] width:40 height:15
	button select_rtoe3_3_btn "3" pos:[85,65] width:40 height:15

	button select_rtoe4_1_btn "1" pos:[5,85] width:40 height:15
	button select_rtoe4_2_btn "2" pos:[45,85] width:40 height:15
	button select_rtoe4_3_btn "3" pos:[85,85] width:40 height:15

	button select_rtoe5_1_btn "1" pos:[5,105] width:40 height:15
	button select_rtoe5_2_btn "2" pos:[45,105] width:40 height:15
	button select_rtoe5_3_btn "3" pos:[85,105] width:40 height:15

	button select_rtoe_all_btn "All R" pos:[90,25] width:30 height:15 tooltip:"All right toes"


	button select_ltoe1_1_btn "1" pos:[5,135] width:25 height:15
	button select_ltoe1_2_btn "2" pos:[30,135] width:25 height:15
	button select_ltoe1_3_btn "3" pos:[55,135] width:25 height:15

	button select_ltoe2_1_btn "1" pos:[5,155] width:40 height:15
	button select_ltoe2_2_btn "2" pos:[45,155] width:40 height:15
	button select_ltoe2_3_btn "3" pos:[85,155] width:40 height:15

	button select_ltoe3_1_btn "1" pos:[5,175] width:40 height:15
	button select_ltoe3_2_btn "2" pos:[45,175] width:40 height:15
	button select_ltoe3_3_btn "3" pos:[85,175] width:40 height:15

	button select_ltoe4_1_btn "1" pos:[5,195] width:40 height:15
	button select_ltoe4_2_btn "2" pos:[45,195] width:40 height:15
	button select_ltoe4_3_btn "3" pos:[85,195] width:40 height:15

	button select_ltoe5_1_btn "1" pos:[5,215] width:40 height:15
	button select_ltoe5_2_btn "2" pos:[45,215] width:40 height:15
	button select_ltoe5_3_btn "3" pos:[85,215] width:40 height:15

	button select_ltoe_all_btn "All L" pos:[90,135] width:30 height:15 tooltip:"All left toes"


	on select_rtoe_all_btn pressed do (
		disableSceneReDraw()
		try (
			local bip = biped_selector_obj.controller
			local toeArr = for i = 1 to (bip.toes * bip.toeLinks) \
				collect(biped.getNode bip 8 link:i)
			select toeArr
			) catch()
		enableSceneRedraw()
		reDrawViews()
	)	

	on select_ltoe_all_btn pressed do (
		disableSceneReDraw()
		try (
			local bip = biped_selector_obj.controller
			local toeArr = for i = 1 to (bip.toes * bip.toeLinks) \
				collect(biped.getNode bip 7 link:i)
			select toeArr
			) catch()
		enableSceneRedraw()
		reDrawViews()
	)	


	on select_rtoe1_1_btn pressed do
		try ( select (biped.getNode biped_selector_obj 8 ) ) catch()
	
	on select_rtoe1_2_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks != 1 then select (biped.getNode biped_selector_obj 8 link:2 )
		) catch()
	)

	on select_rtoe1_3_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 8 link:3 )
		) catch()
	)

	on select_rtoe2_1_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 8 link:4 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 8 link:3 )
		if biped_selector_obj.controller.toelinks == 1 then select (biped.getNode biped_selector_obj 8 link:2 )
		) catch()
	)
	
	on select_rtoe2_2_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 8 link:5 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 8 link:4 )
		) catch()
	)
	
	on select_rtoe2_3_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 8 link:6 )
		) catch()
	)

	on select_rtoe3_1_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 8 link:7 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 8 link:5 )
		if biped_selector_obj.controller.toelinks == 1 then select (biped.getNode biped_selector_obj 8 link:3 )
		) catch()
	)
		
	on select_rtoe3_2_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 8 link:8 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 8 link:6 )
		) catch()
	)

	on select_rtoe3_3_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 8 link:9 )
		) catch()
	)

	on select_rtoe4_1_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 8 link:10 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 8 link:7 )
		if biped_selector_obj.controller.toelinks == 1 then select (biped.getNode biped_selector_obj 8 link:4 )
		) catch()
	)

	on select_rtoe4_2_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 8 link:11 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 8 link:8 )
		) catch()
	)

	on select_rtoe4_3_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 8 link:12 )
		) catch()
	)

	on select_rtoe5_1_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 8 link:13 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 8 link:9 )
		if biped_selector_obj.controller.toelinks == 1 then select (biped.getNode biped_selector_obj 8 link:5 )
		) catch()
	)

	on select_rtoe5_2_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 8 link:14 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 8 link:10 )
		) catch()
	)
	
	on select_rtoe5_3_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 8 link:15 )
		) catch()
	)



	on select_ltoe1_1_btn pressed do
		try ( select (biped.getNode biped_selector_obj 7 ) ) catch()
	
	on select_ltoe1_2_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks != 1 then select (biped.getNode biped_selector_obj 7 link:2 )
		) catch()
	)

	on select_ltoe1_3_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 7 link:3 )
		) catch()
	)

	on select_ltoe2_1_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 7 link:4 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 7 link:3 )
		if biped_selector_obj.controller.toelinks == 1 then select (biped.getNode biped_selector_obj 7 link:2 )
		) catch()
	)
	
	on select_ltoe2_2_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 7 link:5 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 7 link:4 )
		) catch()
	)
	
	on select_ltoe2_3_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 7 link:6 )
		) catch()
	)

	on select_ltoe3_1_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 7 link:7 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 7 link:5 )
		if biped_selector_obj.controller.toelinks == 1 then select (biped.getNode biped_selector_obj 7 link:3 )
		) catch()
	)
		
	on select_ltoe3_2_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 7 link:8 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 7 link:6 )
		) catch()
	)

	on select_ltoe3_3_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 7 link:9 )
		) catch()
	)

	on select_ltoe4_1_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 7 link:10 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 7 link:7 )
		if biped_selector_obj.controller.toelinks == 1 then select (biped.getNode biped_selector_obj 7 link:4 )
		) catch()
	)

	on select_ltoe4_2_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 7 link:11 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 7 link:8 )
		) catch()
	)

	on select_ltoe4_3_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 7 link:12 )
		) catch()
	)

	on select_ltoe5_1_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 7 link:13 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 7 link:9 )
		if biped_selector_obj.controller.toelinks == 1 then select (biped.getNode biped_selector_obj 7 link:5 )
		) catch()
	)

	on select_ltoe5_2_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 7 link:14 )
		if biped_selector_obj.controller.toelinks == 2 then select (biped.getNode biped_selector_obj 7 link:10 )
		) catch()
	)
	
	on select_ltoe5_3_btn pressed do (
		try (
		if biped_selector_obj.controller.toelinks == 3 then select (biped.getNode biped_selector_obj 7 link:15 )
		) catch()
	)
)
addRollout toes_roll biped_float rolledUp:true


rollout ponytail_roll "Ponytails"

(
	label script "Ponytail 1 and 2"

	button select_ptail1_all_btn "ALL 1" pos:[20,25] width:40 height:15 tooltip:"All ponytail 1 objects"
	
	button select_ptail2_all_btn "ALL 2" pos:[75,25] width:40 height:15 tooltip:"All ponytail 2 objects"

	button select_ptail1_1_btn "1" pos:[5,45] width:20 height:15
	button select_ptail1_2_btn "2" pos:[30,45] width:20 height:15
	button select_ptail1_3_btn "3" pos:[55,45] width:20 height:15
	button select_ptail1_4_btn "4" pos:[80,45] width:20 height:15
	button select_ptail1_5_btn "5" pos:[105,45] width:20 height:15

	button select_ptail2_1_btn "1" pos:[5,65] width:20 height:15
	button select_ptail2_2_btn "2" pos:[30,65] width:20 height:15
	button select_ptail2_3_btn "3" pos:[55,65] width:20 height:15
	button select_ptail2_4_btn "4" pos:[80,65] width:20 height:15
	button select_ptail2_5_btn "5" pos:[105,65] width:20 height:15


	on select_ptail1_all_btn pressed do (
		disableSceneRedraw()
		clearNodeSelection()
		for i=1 to 5 do (try ( selectMore (biped.getNode biped_selector_obj 18 link:i ) ) catch() )
		enableSceneRedraw()
		reDrawViews()
	)

	on select_ptail2_all_btn pressed do (
		disableSceneRedraw()
		clearNodeSelection()
		for i=1 to 5 do (try ( selectMore (biped.getNode biped_selector_obj 19 link:i ) ) catch() )
		enableSceneRedraw()
		reDrawViews()
	)

	on select_ptail1_1_btn pressed do
		try ( select (biped.getNode biped_selector_obj 18 ) ) catch()
	on select_ptail1_2_btn pressed do
		try ( select (biped.getNode biped_selector_obj 18 link:2) ) catch()
	on select_ptail1_3_btn pressed do
		try ( select (biped.getNode biped_selector_obj 18 link:3) ) catch()
	on select_ptail1_4_btn pressed do
		try ( select (biped.getNode biped_selector_obj 18 link:4) ) catch()
	on select_ptail1_5_btn pressed do
		try ( select (biped.getNode biped_selector_obj 18 link:5) ) catch()

	on select_ptail2_1_btn pressed do
		try ( select (biped.getNode biped_selector_obj 19 ) ) catch()
	on select_ptail2_2_btn pressed do
		try ( select (biped.getNode biped_selector_obj 19 link:2 ) ) catch()
	on select_ptail2_3_btn pressed do
		try ( select (biped.getNode biped_selector_obj 19 link:3) ) catch()
	on select_ptail2_4_btn pressed do
		try ( select (biped.getNode biped_selector_obj 19 link:4) ) catch()
	on select_ptail2_5_btn pressed do
		try ( select (biped.getNode biped_selector_obj 19 link:5) ) catch()

)
addRollout ponytail_roll biped_float rolledUp:true


rollout tail_roll "Tail"
(


	button select_tail_all_btn "ALL" pos:[45,5] width:40 height:15 tooltip:"All tail objects"

	button select_tail1_btn "1" pos:[5,25] width:20 height:15
	button select_tail2_btn "2" pos:[30,25] width:20 height:15
	button select_tail3_btn "3" pos:[55,25] width:20 height:15
	button select_tail4_btn "4" pos:[80,25] width:20 height:15
	button select_tail5_btn "5" pos:[105,25] width:20 height:15


	on select_tail_all_btn pressed do (
		disableSceneRedraw()
		clearNodeSelection()
		for i=1 to 5 do (try ( selectMore (biped.getNode biped_selector_obj 10 link:i ) ) catch() )
		enableSceneRedraw()
		reDrawViews()
	)

	on select_tail1_btn pressed do
		try ( select (biped.getNode biped_selector_obj 10 ) ) catch()
	on select_tail2_btn pressed do
		try ( select (biped.getNode biped_selector_obj 10 link:2) ) catch()
	on select_tail3_btn pressed do
		try ( select (biped.getNode biped_selector_obj 10 link:3) ) catch()
	on select_tail4_btn pressed do
		try ( select (biped.getNode biped_selector_obj 10 link:4) ) catch()
	on select_tail5_btn pressed do
		try ( select (biped.getNode biped_selector_obj 10 link:5) ) catch()

)
addRollout tail_roll biped_float rolledUp:true


rollout about_roll "About"
(
	label script "Biped Selector 1.3"
	label author1 "Saku Partamies"
	label web1 "www.partamies.com"
	label lab1 "and"
	label author2 "Juha Takabe"
	label web2 "www.saunalahti.fi/jukota/"
	label year "2002"

)
addRollout about_roll biped_float rolledUp:true

)

)